package com.lagou.hw1;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class IntegerDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //1.获取job
        Configuration config = new Configuration();
        Job job = Job.getInstance(config);

        //2.设置Jar
        job.setJarByClass(IntegerDriver.class);

        //3.设置mapper和reducer类
        job.setMapperClass(IntegerMapper.class);
        job.setReducerClass(IntegerReducer.class);

        //4.设置Map输出
        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(NullWritable.class);

        //5.设置reducer输出
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);

        //6.设置输入和输出路径
        FileInputFormat.setInputPaths(job,"G:\\LADOU\\正式班\\作业\\data");
        FileOutputFormat.setOutputPath(job,new Path("G:\\LADOU\\正式班\\作业\\data-out"));

        //7.提交作业
        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0 : 1);
    }
}
